#ifndef _FLYWEIGHT_H_
#define _FLYWEIGHT_H_

#include <string>
#include <list>
using namespace std;
using STATE = string;

class Flyweight
{
public:
    virtual ~Flyweight();
    STATE GetIntrinsicState();
    virtual void Operation(STATE& ExtrinsicState) = 0;
protected:
    Flyweight(const STATE& state);
private:
    STATE _state;
};

class FlyweightFactory
{
public:
    FlyweightFactory();
    ~FlyweightFactory();
    Flyweight* GetFlyweight(const STATE& key);
private:
    list<Flyweight*> _listFlyweight;
};

class ConcreteFlyweight : public Flyweight
{
public:
    ConcreteFlyweight(const STATE& state);
    virtual ~ConcreteFlyweight();
    virtual void Operation(STATE& ExtrinsicState);
};
#endif // _FLYWEIGHT_H_